﻿using QFramework;

namespace HKTools
{
    /// <summary>
    /// 初始化并开启 串口通信
    /// </summary>
    public class CMD_OpenSerialPort : AbstractCommand
    {
        int revLength = 0;

        public CMD_OpenSerialPort(int revLength)
        {
            this.revLength = revLength;
        }

        protected override void OnExecute()
        {
            if (revLength <= 0)
            {
                HKDebug.LogError("串口接收数据长度不能小于0！");
                return;
            }

#if NET_4_6
            this.GetSystem<IHK_SerialPortSystem>().InitSerialPort(revLength);
            this.GetSystem<IHK_SerialPortSystem>().OpenSerialPort();
#endif
        }
    }
}